Repository navigation
[components][libc] cplusplus_system_init 补上 .init_array 的构造函数 - #11856
cms19859230182-lang wants to merge 1 commit into
Conversation
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
🏷️ Tag: components_libcReviewers: @GorrayLi @mysterywolf Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-10-09 23:13 CST)
📝 Review Instructions
|
38e2573 to
479b204
Compare
Newer GCC emits C++ global constructors into .init_array, which many linker scripts keep outside [__ctors_start__, __ctors_end__), so they never ran. Walk __init_array_start/__init_array_end (weak) as well, skipping entries already covered by the ctors range. Add RT_USING_CPP_CRT_INIT for ports whose startup runtime already runs constructors, default on for the simulator, to avoid running them twice. Fixes RT-Thread#11778
479b204 to
5dd7cfa
Compare
拉取/合并请求描述:(PR description)
为什么提交这份PR (why to submit this PR)
Newer GCC puts C++ global constructors into
.init_arrayinstead of the__ctors_start__/__ctors_end__range, socplusplus_system_init()missedthem on ports whose linker script does not merge
.init_arrayinto the ctorsrange. Fixes #11778
你的解决方案是什么 (what is your solution)
Walk
__init_array_start/__init_array_endas well. Both ranges are declaredweak, and each
.init_arrayentry that already lies inside the ctors range isskipped, so full or partial overlap never runs a constructor twice.
Add the Kconfig option
RT_USING_CPP_CRT_INITfor ports whose startupruntime already calls constructors (default on for the simulator, where glibc
runs
.init_arraybeforemain).请提供验证的bsp和config (provide the config and bsp)
BSP: bsp/simulator
.config: CONFIG_RT_USING_CPLUSPLUS=y, CONFIG_RT_USING_CPP_CRT_INIT=y
A global constructor runs exactly once. A host test also covers the ctors
and init_array range combinations.
action: CI link will be added once checks finish.
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up